<%@page language="java" pageEncoding="utf-8" %>
<%@page import="cn.com.wxd.common.DateUtil" %>
<%@page import="cn.com.wxd.util.service.ProjectInfo" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath =
            request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<!DOCTYPE html>
<head>
    <base href="<%=basePath %>">
    <title><%=ProjectInfo.getCompanyName() %>注册</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="favicon.ico"/>
</head>

<link rel="stylesheet" type="text/css" href="static/admin/lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="static/admin/css/theme.css">
<link rel="stylesheet" href="static/admin/lib/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="static/util/css/loaders.min.css"/>
<style type="text/css">
    #line-chart {
        height: 300px;
        width: 800px;
        margin: 0px auto;
        margin-top: 1em;
    }

    .brand {
        font-family: georgia, serif;
    }

    .brand .first {
        color: #ccc;
        font-style: italic;
    }

    .brand .second {
        color: #fff;
        font-weight: bold;
    }

    /**
    *这些样式用于调整动态图标的位置和样式
    **/
    #loader > div {
        background-color: #494949;
    }

    #loader {
        margin-left: 150px;
    }
</style>
</head>

<body class="">
<!--<![endif]-->

<div class="navbar">
    <div class="navbar-inner">
        <ul class="nav pull-right">

        </ul>
        <a class="brand" href="#"><span class="first"><%=ProjectInfo.getCompanyName() %></span> <span class="second">后台管理注册</span></a>
    </div>
</div>
<div class="row-fluid">
    <div class="dialog">
        <div class="block">
            <p class="block-heading">注 册</p>
            <div class="block-body">
                <form id="registerForm" action="admin/applyfor" method="post"
                      onsubmit=" return submitform()">
                    <label>用户名&nbsp;&nbsp;<span style="font-size:12px;color:red;" id="userNameError"></span></label>
                    <input type="text" name="userName" maxlength="24"  placeholder="必填项" required="required"  id="userName" class="span12" />
                    <label>昵&nbsp;称&nbsp;&nbsp;<span style="font-size:12px;color:red;" id="nickNameError"></span></label>
                    <input type="text" name="nickName" maxlength="12"  id="nickName" class="span12" />
                    <label>性&nbsp;别</label>
                    <input type="radio" name="sex" checked="checked" value="男">&nbsp;男</input>&nbsp;&nbsp;&nbsp;<input type="radio" name="users.sex" value="女">&nbsp;女</input>
                    <label>年&nbsp;龄</label>
                    <input type="number" name="age" maxlength="3" min="0" max="120" step="1" value="23" class="span6"/>
                    <label>密&nbsp;码&nbsp;&nbsp;<span style="font-size:12px;color:red;" id="passWordError"></span></label>
                    <input type="password" maxlength="16" name="password"  placeholder="必填项" required="required"
                           id="passWord" autocomplete="off" class="span12"/>
                    <label>确认密码&nbsp;&nbsp;<span style="font-size:12px;color:red;" id="repassWordError"></span></label>
                    <input type="password" maxlength="16" name="rePassword"  placeholder="必填项" required="required"
                           id="repassWord" autocomplete="off" class="span12"/>
                    <label>邮&nbsp;箱&nbsp;&nbsp;<span style="font-size:12px;color:red;" id="emailError"></span></label>
                    <input type="email" name="email"  id="eamil" class="span12" />
                    <label>电&nbsp;话&nbsp;&nbsp;<span style="font-size:12px;color:red;" id="phoneError"></span></label>
                    <input type="phone" name="phone" id="phone" class="span12"/>
                    <label>验证码&nbsp;&nbsp;<span style="font-size:12px;color:red;" id="verCodeError"></span></label>
                    <input type="text" name="verCode" id="verCode" required="required" maxlength="4" placeholder="必填项" class="span6"/>
                    <img id="vercodeimg" alt="点击切换图片" title="点击切换图片" style="width:85px;height:25px" border="0" src="vercode/vercodeQQ?time=<%=DateUtil.getTimestamp()%>"/>
                    <br/>
                    <span id="submitA"><input class="btn btn-primary pull-right"  type="submit" value="提交审核"/></span>
                    <div class="clearfix" style="font-size:12px;color:red;">${requestScope.actionError}</div>
                </form>
            </div>
        </div>
        <p>注册前请<a target="_blank" href="admin/login">阅读相关协议</a>,有账号？去
            <a href="admin/login">登陆</a></p>
    </div>
</div>
</body>
<script type="text/javascript" src="static/js/jquery1-11-3.min.js"></script>
<script type="text/javascript" src="static/js/base64.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#vercodeimg").click(function () {
                $("#vercodeimg").attr("src", "vercode/vercodeQQ?time=" + new Date());
            }
        );
    });
    function submitform() {
        var password = $("#passWord").val();
        var repassword = $("#repassWord").val();
        var userName = $("#userName").val();
        var vercode = $("#verCode").val();
        var nickname = $("#nickName").val();
        var phone = $("#phone").val();
        var email = $("#email").val();
        if (userName == "") {
            $("#userNameError").html("用户名不能为空！");
            setTimeout(function () {
                $("#userNameError").html("");
            }, 3000);
            return false;
        } else {
            var usern = /^[a-zA-Z0-9_]{1,}$/;
            if (!usern.test(userName)) {
                $("#userNameError").html("用户名只能为字母开头,数字,_,3者组成！");
                setTimeout(function () {
                    $("#userNameError").html("");
                }, 3000);
                return false;
            }
            if (userName.length < 6) {
                $("#userNameError").html("用户名长度不能小于6！");
                setTimeout(function () {
                    $("#userNameError").html("");
                }, 3000);
                return false;
            }
        }
        if (password == "") {
            $("#passWordError").html("密码不能为空！");
            setTimeout(function () {
                $("#passWordError").html("");
            }, 3000);
            return false;
        }
        if (password.length < 6) {
            $("#passWordError").html("密码长度不能小于6！");
            setTimeout(function () {
                $("#passWordError").html("");
            }, 3000);
            return false;
        }
        if (repassword == "") {
            $("#repassWordError").html("确认密码不能为空！");
            setTimeout(function () {
                $("#repassWordError").html("");
            }, 3000);
            return false;
        }
        if (password != repassword) {
            $("#repassWordError").html("两次密码输入不一致！");
            setTimeout(function () {
                $("#repassWordError").html("");
            }, 3000);
            return false;
        }
        //var reg=/[a-zA-Z0-9_.$]{1,20}@[a-zA-Z0-9]{1,5}\.[a-zA-Z0-9]{1,5}/;
        //if(email!=""){
        //	if(!reg.test(email)){
        //	 	$("#emailError").html("邮箱格式不正确！");
        //		setTimeout(function(){
        //			$("#emailError").html("");
        //		},3000);
        //		return false;
        //	}
        //}
        if (phone != "") {
            var re = /^1\d{10}$/;
            if (!re.test(phone)) {
                $("#phoneError").html("手机号码格式不正确！");
                setTimeout(function () {
                    $("#phoneError").html("");
                }, 3000);
                return false;
            }
        }
        if (vercode == "") {
            $("#verCodeError").html("验证码不能为空！");
            setTimeout(function () {
                $("#verCodeError").html("");
            }, 3000);
            return false;
        }
        if (nickname.length > 10) {
            $("#nickNameError").html("昵称长度不能大于10个字！");
            setTimeout(function () {
                $("#nickNameError").html("");
            }, 3000);
            return false;
        }
        try {
            $("#passWord").val(encode64(password));  //进行加密
            $("#repassWord").val(encode64(repassword));  //进行加密
        } catch (e) {

            return false;
        }
        $("#submitA").html("<div id=\"loader\" class=\"loader-inner ball-pulse\"><div></div><div></div><div></div></div>");
        return true;
    }
</script>
</html>
